// src/stores/sound.js
import { defineStore } from 'pinia'

export const useSoundStore = defineStore('sound', {
  state: () => ({
    userInteracted: false, // 用户是否已交互（点击过）
    soundEnabled: true, // 用户是否允许播放声音
  }),

  actions: {
    markUserInteracted() {
      this.userInteracted = true
    },
    setSoundEnabled(enabled) {
      this.soundEnabled = enabled
    }
  },

  // ✅ 使用 persistedstate 插件的语法
  persist: {
    key: 'sound',
    paths: ['userInteracted', 'soundEnabled'],
    storage: localStorage
  }
})